﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace XMLSchemaExtractor.Utility
{
    public static class Common
    {
        public static bool IsXmlWellFormed(string filePath)
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.DtdProcessing = DtdProcessing.Ignore;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;

            using (XmlReader xr = XmlReader.Create(filePath, settings))
            {
                try
                {
                    while (xr.Read()) { }
                }
                catch (Exception)
                {
                    return false;
                }
                return true;
            }
        }
    }
}
